<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const fileTypeMapping = new Map([
            ['md', 'markdown'],
            ['doc', 'word'],
            ['docx', 'word'],
            ['html', 'web'],
            ['xls', 'excel'],
        ]);

        const input = [
            'js-this.md',
            'vue.docx',
            'js-class.md',
            'react.xixi.doc',
            'mp.xls',
            'fe06.xls',
            'fe06.heihei.xls',
            'index.html',
        ];

        const output = {
            word: 2,
            markdown: 2,
            excel: 3,
            web: 1,
        };

        function getFileCount(input) {
            return input.reduce((prev, current) => {
                const suffix = current.split('.').pop();
                const fileType = fileTypeMapping.get(suffix);
                if (!prev[fileType]) {
                    prev[fileType] = 1;
                } else {
                    prev[fileType]++;
                }
                return prev;
            },{})
        }
        console.log(getFileCount(input));
    </script>
</body>
</html>